package com.lingjoin.manager.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.lingjoin.manager.mybatis.model.User;
import com.lingjoin.manager.service.UserService;

@Controller
@RequestMapping(value = "/manager")
public class TestController {
	
	@Autowired
	public UserService userService;
	
	@RequestMapping(value = "/test")
	public ModelAndView test() {
		return  new  ModelAndView("e");
	}
	
	@RequestMapping(value = "/test2")
	@ResponseBody
	public String test2() {
		
		return  "\"a\":123";
	}
	
	@RequestMapping(value = "/test3")
	@ResponseBody
	public ModelMap test3() {
		
		ModelMap map=new ModelMap();
		map.put("1111", userService.pub());
		return  map;
	}
	
	@RequestMapping(value = "/test4")
	@ResponseBody
	public ModelMap test4(User  u) {
		
		ModelMap map=new ModelMap();
		userService.adduser(u);
		map.put("flag", "success");
		return  map;
	}
	
	@RequestMapping(value = "/test5")
	@ResponseBody
	public ModelMap test5(User  u) {
		
		ModelMap map=new ModelMap();
		userService.save(u);
		map.put("flag", "success");
		return  map;
	}
	
}
